<?php

namespace app\cron\controller;

use think\Controller;
use app\common\service\FaceRecognitionService as CommonFaceRecognitionService;

/**
 * 百度人脸识别脚本
 *
 * @author jiang.ding
 */

class FaceRecognition extends Controller{

    /**
     * 初始化
     */
   public function __construct(\think\Request $request = null) {
        parent::__construct($request);
    }

    /**
     * 抓拍脚本
     * @param string $companyId 集团ID [目前为宝岛定制版]
     */
    public function addCameraPic($companyId = 1)
    {
        $camera = new CommonFaceRecognitionService();
        # 轮询
        while (true) {
            try {

                $cameraRes = $camera->addCameraPic($companyId);
            } catch (\Exception $e) {

                # 报警通知工作人员(待写:邮箱类)

                echo $e->getMessage() . "\n";
                echo date('Y-m-d H:i:s') . "\n";
                $cameraRes = $camera->addCameraPic($companyId);
            }
            sleep(10);
        }
    }
   
}
